<template>
  <div class="total" ref="total">
    <div>
      <div class="scro">
        <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
          <van-swipe-item
            :key="'banners_' + index"
            v-for="(item, index) in bannerList"
            ><img v-lazy="item.pic" alt=""
          /></van-swipe-item>
        </van-swipe>
      </div>
      <div class="rukou">
        <MySwiper :perview="3.5" :key="'swiper_rukou' + rukou.length">
          <div
            style="width: 100px ,height:100px"
            class="swiper-slide rukou_box"
            :key="'rukou_' + index"
            v-for="(item, index) in rukou"
            @click="give"
          >
            <img v-lazy="item.iconUrl" alt="" />
            <span class="blank">{{ item.name }}</span>
          </div>
        </MySwiper>
      </div>
      <div class="recommend">
        <div class="top">
          <h3>推荐歌单</h3>
          <span>查看更多</span>
        </div>
        <div class="foot">
          <div class="cart">
            <MySwiper :perview="2.5" :key="'swiper_recomd' + recomd.length">
              <div
                style="width: 160px"
                class="swiper-slide"
                :key="'recomd_' + index"
                v-for="(item, index) in recomd"
              >
                <img v-lazy="item.picUrl" alt="" />
                <span class="blank">{{ item.name | Tostr }}</span>
                <div class="count">▷ {{ item.playCount | Num }}万</div>
              </div>
            </MySwiper>
          </div>
        </div>
      </div>
      <!-- 专属场景歌曲 -->
      <div class="recommend">
        <div class="top">
          <h3>新碟</h3>
          <span>查看更多</span>
        </div>
        <div class="foot">
          <div class="cart">
            <MySwiper :perview="2.5" :key="'swiper_recomd' + newD.length">
              <div
                style="width: 160px,height:160px"
                class="swiper-slide"
                :key="'newD_' + index"
                v-for="(item, index) in newD"
              >
                <img v-lazy="item.picUrl" alt="" />
              </div>
            </MySwiper>
          </div>
        </div>
      </div>

      <router-view></router-view>
    </div>
  </div>
</template>
<script>
import Vue from "vue";
import { Tab, Tabs, Swipe, SwipeItem, Lazyload, Skeleton, Toast } from "vant";
Vue.use(Tab);
Vue.use(Tabs);
Vue.use(Swipe);
Vue.use(SwipeItem);
Vue.use(Lazyload);
Vue.use(Skeleton);
Vue.use(Toast);
import MySwiper from "../components/Swiper";
import BScroll from "better-scroll";
export default {
  data() {
    return {
      bannerList: [],
      recomd: [],
      loading: true,
      newD: [],
      rukou: [],
    };
  },
  methods: {
    give() {
      Toast("功能尚未开放");
    },
  },
  components: {
    MySwiper,
  },
  created() {},
  async mounted() {
    loading: false;
    const ret = await this.$http.get("http://localhost:3000/banner?type=1");
    console.log(22222);
    console.log(ret);
    this.bannerList = ret.banners;
    const rec = await this.$http.get(
      "http://localhost:3000/personalized?limit=6"
    );
    this.recomd = rec.result;
    const result = await this.$http.get(
      " http://localhost:3000/album/new?area=KR&limit=4"
    );
    this.newD = result.albums;
    const rukou = await this.$http.get(
      "http://localhost:3000/homepage/dragon/ball"
    );
    this.rukou = rukou.data;
  },
  updated() {
    this.height1 = document.documentElement.clientHeight;
    this.$nextTick(() => {
      this.bs = new BScroll(this.$refs["total"], {
        pullUpLoad: true,
        pullDownRefresh: true,
        click: true,
      });
    });
  },
};
</script>
<style lang="scss" scoped>
.rukou {
  height: 100px;
  width: 345px;
  padding: 0 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
  .rukou_box {
    height: 100px;
    width: 100px;
    margin-top: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    img {
      width: 60px;
      height: 60px;
      border-radius: 50%;
      background-color: red;
    }
  }
}
.total {
  overflow: hidden;
}
.blank {
  font-size: 14px;
}
.count {
  width: 100px;
  height: 30px;
  // background-color: red;
  position: absolute;
  top: 5px;
  right: -25px;
  color: #f4f4f4;
  font-size: 14px;
}
.scro {
  width: 345px;
  padding: 0 15px;
}
van-swipe {
  width: 100%;
  height: 100%;
  border-radius: 8px;
}
// 插件轮播图
.my-swipe .van-swipe-item {
  border-radius: 8px;
  height: 150px;
  margin-top: 15px;
  color: #fff;
  font-size: 20px;
  text-align: center;
  background-color: #39a9ed;
  width: 345px;
  img {
    border-radius: 8px;
    width: 100%;
    height: 100%;
  }
}
.swiper-container {
  width: 345px;
  height: 150px;
  margin-left: 15px;
  border-radius: 8px;
  margin: 8px auto;
  .card {
    margin: 0 auto;
    width: 345px;
    border-radius: 8px;
    height: 150px;
    img {
      display: block;
      width: 345px;
      height: 150px;
      border-radius: 8px;
    }
  }
}
/deep/ .van-tabs {
  margin-top: 20px;
}
/deep/ .van-tabs van-tabs--card {
  border: none;
}
/deep/ .van-tabs--card > .van-tabs__wrap {
  height: 60px;
}
/deep/ .van-tabs__nav--card {
  height: 60px;
  border: none !important;
}

/deep/ .van-tabs__nav--card .van-tab {
  text-align: center;
  border-radius: 50%;
  width: 60px;
  border-right: none !important;
}
.recommend {
  margin-top: 20px;
  .top {
    display: flex;
    width: 345px;
    padding: 0 15px;
    height: 40px;
    justify-content: space-between;
    span {
      border: 1px solid #ddd;
      height: 25px;
      line-height: 25px;
      font-size: 12px;
      padding: 0 10px;
      border-radius: 19px;
    }
  }
}
.cart {
  margin-left: 15px;
  position: relative;
  width: 120px;
  img {
    margin-right: 10px;
    width: 120px;
    height: 120px;
    border-radius: 8px;
  }
}
</style>
